package com.yxinsur.imc.web.controller.business;

import com.yxinsur.imc.business.form.FundForm;
import com.yxinsur.imc.business.form.FundSaveForm;
import com.yxinsur.imc.business.service.IImcFundService;
import com.yxinsur.imc.common.annotation.Log;
import com.yxinsur.imc.common.core.controller.BaseController;
import com.yxinsur.imc.common.core.domain.AjaxResult;
import com.yxinsur.imc.common.core.page.TableDataInfo;
import com.yxinsur.imc.common.enums.BusinessType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 基本法配置主Controller
 *
 * @author imc
 * @date 2021-05-25
 */
@Api(value="基本法配置服务信息接口",tags={"基本法配置服务信息接口"})
@RestController
@RequestMapping("/business/fund")
public class ImcFundController extends BaseController {
    @Autowired
    private IImcFundService imcFundService;

    /**
     * 查询基本法配置主列表
     */
    @ApiOperation("查询基本法配置列表")
    @GetMapping("/list")
    public TableDataInfo list(FundForm fundForm) {
        startPage();
        return getDataTable(imcFundService.selectImcFundList(fundForm));
    }

    /**
     * 获取基本法配置主详细信息
     */
    @ApiOperation("根据id获得基本法配置详情")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(imcFundService.selectImcFundById(id));
    }

    /**
     * 新增基本法配置主
     */
    @ApiOperation("新增佣金口径配置")
    @Log(title = "新增佣金口径配置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FundSaveForm fundSaveForm) {
        return toAjax(imcFundService.insertImcFund(fundSaveForm));
    }

    /**
     * 修改基本法配置主
     */
    @Log(title = "修改佣金口径配置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FundSaveForm fundSaveForm) {
        return toAjax(imcFundService.updateImcFund(fundSaveForm));
    }

    /**
     * 删除基本法配置主
     */
    @Log(title = "删除佣金口径配置", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(imcFundService.deleteImcFundByIds(ids));
    }
}
